/*
 * Copyright 2020-2030 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/

package com.gitee.minimalismstyle.fresh.flowable.api.feign

import org.springframework.web.bind.annotation.*
import com.gitee.minimalismstyle.fresh.common.core.domain.R
import com.gitee.minimalismstyle.fresh.flowable.api.annotation.FlowableClient
import com.gitee.minimalismstyle.fresh.flowable.api.config.FlowableFeignConfig
import com.gitee.minimalismstyle.fresh.flowable.api.feign.fallback.BatchesApiFallback
import com.gitee.minimalismstyle.fresh.flowable.api.feign.model.BatchResponse
import com.gitee.minimalismstyle.fresh.flowable.api.feign.model.DataResponse

/**
 * Batches
 * @author maoxiaodong
 */
@FlowableClient(configuration = [FlowableFeignConfig::class], fallback = BatchesApiFallback::class)
interface BatchesApi {


    /**
     * Get the batch part document
     */
    @GetMapping("/management/batch-parts/{batchPartId}/batch-part-document")
    fun getBatchPartDocument(
        @PathVariable("batchPartId") batchPartId: String
    ): R<Any>

    /**
     * List batches
     */
    @GetMapping("/management/batches")
    fun listBatches(
        @RequestParam(name = "id", required = false) id: String?,
        @RequestParam(name = "batchType", required = false) batchType: String?,
        @RequestParam(name = "searchKey", required = false) searchKey: String?,
        @RequestParam(name = "searchKey2", required = false) searchKey2: String?,
        @RequestParam(name = "createTimeBefore", required = false) createTimeBefore: String?,
        @RequestParam(name = "createTimeAfter", required = false) createTimeAfter: String?,
        @RequestParam(name = "completeTimeBefore", required = false) completeTimeBefore: String?,
        @RequestParam(name = "completeTimeAfter", required = false) completeTimeAfter: String?,
        @RequestParam(name = "status", required = false) status: String?,
        @RequestParam(name = "tenantId", required = false) tenantId: String?,
        @RequestParam(name = "tenantIdLike", required = false) tenantIdLike: String?,
        @RequestParam(name = "withoutTenantId", required = false) withoutTenantId: Boolean?
    ): R<DataResponse<BatchResponse>>

    /**
     * Get a single batch
     */
    @GetMapping("/management/batches/{batchId}")
    fun getBatch(
        @PathVariable("batchId") batchId: String
    ): R<BatchResponse>

    /**
     * Delete a batch
     */
    @DeleteMapping("/management/batches/{batchId}")
    fun deleteBatch(
        @PathVariable("batchId") batchId: String
    ): R<Any>

    /**
     * Get the batch document
     */
    @GetMapping("/management/batches/{batchId}/batch-document")
    fun getBatchDocument(
        @PathVariable("batchId") batchId: String
    ): R<Any>

    /**
     * List batch parts
     */
    @GetMapping("/management/batches/{batchId}/batch-parts")
    fun listBatchesPart(
        @PathVariable("batchId") batchId: String,
        @RequestParam(name = "status", required = false) status: String?
    ): R<Any>
}